‫Welcome back, this is just six in the previous letter we wrote this.
‫We cleaned it up a little bit so that it was able to allow guests to post request.
‫And we also made sure that the response that we are returning is additionally.
‫And that made it easy.
‫That makes it easy for consumption by our front end application.
‫Now, in this lecture, I want us to send different other things with the response they are getting
‫from our API.
‫And what they would like us to do here is to give the user a message like when maybe the response they'll
‫be successful when it is not successful.
‫And what they like to do here is I come on the top of my file here and I define two things.
‫Two to two variables.
‫One, I called the success and this was of this contains 200 and the other one I call not found.
‫This one I can give supply four hundred.
‫And what I am going to do here now is to check whether so I'm going to write a condition.
‫Sorry, I'm going to read up on this one here that if my items has anything, OK, if my items are saying
‫that you remember this is only for the purpose of this demo.
‫If my items has anything, then I want this thing to compose a body to to give it as good as gold equals
‫success.
‫You remember the success that we need up there.
‫Code is going to be success.
‫This is not not a success.
‫It is a success.
‫So it is success, status quo, status good is going to be success.
‫And then the body that I want to pass are my items.
‫OK, so I have those two things.
‫There I am.
‫Come here and see if this thing is not, then I am going to pass status as quote listed as good.
‫I'm going to pass here is not found item and then the body here is going to be maybe a string.
‫Seeing the item you are looking for is not found.
‫You can again pass whatever kind of message on to pass here.
‫And then here I have about Devastator scored in all of them.
‫And then what I'm going to do here next is that I am going not to compose my response.
‫Right.
‫And then went to see response.
‫This is very important.
‫Response is, of course, additionally, I want to return a dictionary, dict the dictionary and then
‫within this dictionary, what I want to pass is two things that is listed as good.
‫Remember, that is what I am doing.
‫This is so that we can have in status status code.
‫And then the next thing that I want to pass here is the body and the body I want to pass.
‫Here is again the body.
‫And what this thing is going to do is and then, of course, I'm going to return now the response.
‫All right.
‫I'm going to return the response.
‫Instead of returning the items, I'm going to redundant the response.
‫So what we have done here is we have created two two variables on top of the file.
‫We have one with 200 and we have one with 400.
‫And then here we have said if I add them, so if we get items from here, what we're going to do is
‫set the status code for success and then the bodies will to contain our items.
‫Otherwise, if this is not found, what are you going to do is that we are going to stay the status
‫quo to not found.
‫And the what is going to be the item you're looking for is not found.
‫Right.
‫And then this is going to make more sense in the next video.
‫When we come back with the next the next of us, a system where we would be creating with separate parameters.
‫And then here we we set up our DNA, we compose it, and then we supply this sort of status code.
‫And the body of what you can call this anything else you want is going to be key and value key and value
‫in our dictionary in our response.
‫So when we save that, then come to our when you save that, then come to a postman and send you can
‫see, you know, the message has changed a little.
‫We have this code of 200 on the body that we are getting here is our our our items.
‫So if we add more than one item, you could see them here.
‫So you're going to see what is going to be happening here as we move on with this tutorial.
‫With this, you're going to see what is going to be happening here when we move on with this series.
‫Thank you so much and see you in the next lecture.